package com.xk.controller;

import com.xk.mapper.TeacherMapper;
import com.xk.pojo.Page;
import com.xk.pojo.Teacher;
import com.xk.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.lang.annotation.Target;
import java.util.ArrayList;
import java.util.List;

@Controller
public class TestController {


    private TeacherMapper mapper;

    @RequestMapping("/f1")
//    @ResponseBody
    public String f1T(){
        System.out.println("这是一个测试");
        return "success";
    }

    @RequestMapping("/f12")
    @ResponseBody
    public String f23(){
        System.out.println("这是一个测试2");
        return "aaa";
    }
    @RequestMapping("/f3")
    @ResponseBody
    public Page f3(){
        System.out.println("这是一个测试3");
        SqlSession sqlSession = MyBatisUtils.getSqlSession();
        mapper = sqlSession.getMapper(TeacherMapper.class);
        List<Teacher> teachers = mapper.getAllTeachers();

        Page page=new Page(0,5,teachers.size());
        page.setDataList(mapper.getTeacherListByPage(0,5,""));

        sqlSession.close();

        return page;
    }
}
